# -*- coding:utf-8 -*-

from tastypie.api import Api
# from project.apis import *
# from datakeeper.apis import *
# from colormap.apis import *
# from dxuser.apis import *
# from account.apis import *
# from mapdata.apis import *
from weblib.django.setting import *
from metlib.misc.misc import *

resources_to_reg = []
mods = get_setting('INSTALLED_APPS')

if mods:
    for mod in mods:
        try:
            api_module_name = mod + '.apis'
            api_reglist_name = api_module_name + '.REGLIST'
            api_reglist = str2obj(api_reglist_name)
            if api_reglist:
                resources_to_reg.extend(api_reglist)
        except ImportError as e:
            print e


fg_api = Api(api_name='fg')

# for to_reg in (
#         ProjectTypeResource,
#         ProjectResource, ProjectItemResource, SnapshotResource,
#         Project_ItemsResource, ProjectItem_SnapshotsResource,
#         DatasetMoldResource,
#         DatasetResource,
#         ColormapResource,
#         DXUserResource,
#         AccountResource,
#         PolygonMapResource,
#         LineMapResource,
#         PointMapResource,
#         ):
#     fg_api.register(to_reg())

for to_reg in resources_to_reg:
    fg_api.register(to_reg())